import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import Unocss from 'unocss/vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    Unocss({}),
    react(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      symbolId: 'icon-[dir]-[name]'
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src') // src 路径
    }
  },
  server: {
    hmr: true,
    proxy: {
      '/mock': {
        target:
          'http://169.254.248.203:10393/mock/7e1e1d69-8e5c-44db-955b-dc1276d4a364',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/mock/, '')
      },
      '/llm': {
        target: 'http://192.168.2.102:7860',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/llm/, '')
      },
      '/langchainServer': {
        target: 'http://192.168.2.158:17777',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/langchainServer/, '')
      }
    }
  }
})
